package com.wqc.dynaproxy;

public class PerformanceMonitor{
    // 通过一个ThreadLocal, 保存与调用线程相关的性能监视信息
    private static ThreadLocal<MethodPerformance> performanceRecord =
            new ThreadLocal<MethodPerformance>();

    // 开始对某一方法进行性能监视
    public static void begin(String method){
        System.out.println("性能监视开始...");
        MethodPerformance mp = new MethodPerformance(method);
        performanceRecord.set(mp);
    }

    // 对某一方法的性能监视结束
    public static void end(){
        System.out.println("性能监视结束...");
        MethodPerformance mp = performanceRecord.get();
        // 打印性能监视结果信息
        mp.printPerformance();
    }
}
